package cn.hzking.gjmall.activitys.login;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.hzking.gjmall.R;
import cn.hzking.gjmall.base.ColorStatuBarActivity;
import cn.hzking.gjmall.net.loading.loadingview.GjLoadingUtils;
import cn.hzking.gjmall.wxapi.WXShare;

public class LoginActivity extends ColorStatuBarActivity {

    @Bind(R.id.wx_login)
    TextView wxLogin;
    @Bind(R.id.phone_login)
    TextView phoneLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
    }

    public void weixinLogin(View view) {
        WXShare.getInstance(this).author();
        GjLoadingUtils.showLoading(this, false);
    }

    public void phoneLogin(View view) {
        Intent intent = new Intent(this,PhoneLoginActivity.class);
        startActivity(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        GjLoadingUtils.stopLoading();
    }

     @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(String event){
        if("close".equals(event)){
           GjLoadingUtils.showLoading(this,false);
        }
    }

  /*  @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent i = new Intent(Intent.ACTION_MAIN);  //主启动，不期望接收数据
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);       //新的activity栈中开启，或者已经存在就调到栈前
            i.addCategory(Intent.CATEGORY_HOME);            //添加种类，为设备首次启动显示的页面
            startActivity(i);
        }
        return super.onKeyDown(keyCode, event);
    }*/

}
